// @ts-nocheck

// 如果没有达到开头的长度 就要记录找到了多少个元素
// 始终要计算结束位置，是否达到

export type Slice<
    T extends any[],
    S extends number,
    E extends number = T["length"],
    SA extends any[] = [], // 记录当前遍历到的个数，达到索引后长度不再变化
    SE extends any[] = [],  // 结束数组会一直累加
    F extends any[] = []
> = T extends [infer L, ...infer R]
    ? SA['length'] extends S
    ? SE['length'] extends E
    ? [...F, L]
    : Slice<R, S, E, SA, [...SE, null], [...F, L]>
    : Slice<R, S, E, [...SA, null], [...SE, null], F> // 有没有达到要截取的部分 Slice<T, 1, 3, [1], [1], []>
    : F;


type A1 = Slice<[any, never, 1, "2", true, boolean], 0, 2>;
type A2 = Slice<[any, never, 1, "2", true, boolean], 1, 3>;
type A3 = Slice<[any, never, 1, "2", true, boolean], 1, 2>;
type A4 = Slice<[any, never, 1, "2", true, boolean], 2>;
type A5 = Slice<[any], 2>;
type A6 = Slice<[], 0>;

export { };